ALTER TABLE Attributesfamilies 
ADD IsEnabledForOptions bit NULL

GO

ALTER PROC [dbo].[GetAttributesFamiliesSelectByTopCount] 
    @TopCount int = 3
AS 
	SET NOCOUNT ON 
	SET XACT_ABORT ON  

	BEGIN TRAN

	If @TopCount = 1111 or @TopCount = 3
	Begin
		SELECT [Id],[Description], IsEnabledForOptions
		FROM   [dbo].[Attributesfamilies] 
		Where IsEnabledForOptions = 1
		order by [Description]
	End
	Else
	Begin
		SELECT [Id],[Description], IsEnabledForOptions
		FROM   [dbo].[Attributesfamilies] 
		Where IsEnabledForOptions = 1
		order by [Description]
	End

	COMMIT
GO

CREATE TYPE [dbo].[utblListIds] AS TABLE(
	ID int NOT NULL,
	PRIMARY KEY CLUSTERED 
(
	ID ASC
)WITH (IGNORE_DUP_KEY = OFF)
)

GO
Create PROC [dbo].[UpdateSelectAttrsForOption](
    @ListAttrIDs dbo.utblListIds readonly
)    
AS 
	SET NOCOUNT ON 
	SET XACT_ABORT ON  
	
	BEGIN TRAN
	
	Update dbo.Attributesfamilies 
	Set IsEnabledForOptions = null
	
	UPDATE dbo.Attributesfamilies 
    SET dbo.Attributesfamilies.IsEnabledForOptions = 1
    FROM dbo.Attributesfamilies INNER JOIN @ListAttrIDs AS ec
    ON dbo.Attributesfamilies.Id = ec.ID
               
	COMMIT
GO	